package com.woniu.user.controller;

import com.woniu.common.ResponseData;
import com.woniu.common.dto.TreeBackDTO;
import com.woniu.common.dto.UserDTO;
import com.woniu.common.dto.UserRoleDTO;
import com.woniu.user.service.TMenusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/menu")
public class MenuController {
    @Autowired
    private TMenusService tMenusService;

    @PostMapping("/queryMenuByRole")
    /**
     * 根据角色查询菜单
     */
    public ResponseData<?> queryMenuByRole(@RequestBody UserDTO userDTO ){
        return tMenusService.queryMenuByRole(userDTO.getId().intValue());
    }


    @PostMapping("/queryAllMenuAndAuth")
    public ResponseData<?> queryAllMenuAndAuth(@RequestBody UserRoleDTO userRoleDTO){
        return tMenusService.queryAllMenuAndAuth(userRoleDTO);
    }

    @PostMapping("/updateMenuAndAuth")
    public ResponseData<?> updateMenuAndAuth(@RequestBody TreeBackDTO treeBackDTO){
        return tMenusService.updateMenuAndAuth(treeBackDTO);
    }

}

